﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ObjectModel;
using SAIPS.Models;

namespace SAIPS.Controllers
{
    public class ProjectController : BaseController<Project>
    {
		public override ActionResult Create()
		{
			var obj = new ProjectModel();
			obj.Products = new Product().select("where removed=0", "Id", "Name").Select(o => new SelectListItem() { Text = o.Name, Value = o.Id.ToString() });
			return View(obj);
		}
		public override ActionResult Index()
		{
			var lst = new Project().select("where produ.removed=0", "Name", "Description", "Product.Name", "Product.Id").Select(p =>
				new ProjectModel() { 
					Description = p.Description, 
					Name = p.Name,
					ProductName = p.Product.Name
				});
			return View(lst);
		}
    }
}
